#include<vector>
using namespace std;

class Solution {
private:
    vector<int>nums;

public:
    Solution(vector<int>& nums):nums(nums){

    }

    int pick(int target) {
        int index = 0;
        int res = 0;
        for (int i = 0; i < nums.size(); ++i) {
            if (nums[i] == target) {
                ++index;
                if (rand() % index == 0)
                    res = i;
            }
        }
        return res;
    }
};

/**
 * Your Solution object will be instantiated and called as such:
 * Solution* obj = new Solution(nums);
 * int param_1 = obj->pick(target);
 */